package com.jinduplan.planmanager.ui.activity.report

import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.cxz.kotlin.baselibs.adapter.CustomRecyclerAdapter
import com.cxz.kotlin.baselibs.adapter.ViewHolder
import com.cxz.kotlin.baselibs.base.BaseMvpTitleActivity
import com.cxz.kotlin.baselibs.widget.UniversalItemDecoration
import com.jinduplan.planmanager.R
import com.jinduplan.planmanager.bean.ReportDetailData
import com.jinduplan.planmanager.bean.ReportListData
import com.jinduplan.planmanager.bean.ReportListRecord
import com.jinduplan.planmanager.constant.Constant
import com.jinduplan.planmanager.mvp.contract.ReportContract
import com.jinduplan.planmanager.mvp.presenter.ReportPresenter
import com.jinduplan.planmanager.utils.ResUtil
import kotlinx.android.synthetic.main.activity_rcy_refresh.*
import kotlinx.android.synthetic.main.activity_register.*

class ReportTypeListAcitivity:
    BaseMvpTitleActivity<ReportContract.View, ReportContract.Presenter>(),ReportContract.View {

    val datas  = ArrayList<String>()
//    override fun initView() {
//        setStatusBarColor(resources.getColor(R.color.transparent_75))
//        setStatusBarIcon(false)
//        super.initView()
//        setBaseTitleColor(android.R.color.white)
//    }

    override fun attachChildLayoutRes(): Int {
        return R.layout.activity_rcy_refresh
    }


    override fun createPresenter(): ReportContract.Presenter {
        return ReportPresenter()
    }

    override fun start() {
        setBaseTitle(ResUtil.getS(R.string.corrupt_report))
        swipeRefreshLayout.isEnabled = false
        setRightIcon({
            startActivity(Intent(this,ReportRecordListAcitivity::class.java))
        })
        datas.add(ResUtil.getS(R.string.report_type_1))
        datas.add(ResUtil.getS(R.string.report_type_2))
        datas.add(ResUtil.getS(R.string.report_type_3))
        recyclerView.adapter = object :CustomRecyclerAdapter<String>(this,R.layout.item_corrupt_report,datas){
            override fun convert(holder: ViewHolder, t: String, position: Int) {
                holder.setText(R.id.tvContent,t)
                when (position) {
                    0->{
                        holder.getView<View>(R.id.viewType).setBackgroundResource(R.color.report_1_jdy)
                    }
                    1->{
                        holder.getView<View>(R.id.viewType).setBackgroundResource(R.color.report_2_jdy)
                    }
                    else->{
                        holder.getView<View>(R.id.viewType).setBackgroundResource(R.color.report_3_jdy)
                    }
                }
                holder.itemView.setOnClickListener {
                    val  intent = Intent(this@ReportTypeListAcitivity,ReportEditAcitivity::class.java)
                    intent.putExtra(Constant.REPORT_TYPE,(position+1).toString())
                    startActivity(intent)
                }
            }

        }
        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.addItemDecoration(object : UniversalItemDecoration() {
            override fun getItemOffsets(position: Int): Decoration {
                val decoration = ColorDecoration()
                decoration.decorationColor = ResUtil.getC(R.color.transparent)
                if (position == 0) {
                    decoration.top = ResUtil.getDimen(this@ReportTypeListAcitivity,R.dimen.dp_23).toInt()
                }
                decoration.bottom = ResUtil.getDimen(this@ReportTypeListAcitivity,R.dimen.dp_12).toInt()
                return decoration
            }

        })
    }

    override fun getDetail(data: ReportDetailData) {
        TODO("Not yet implemented")
    }

    override fun reportSuccess() {
        TODO("Not yet implemented")
    }

    override fun uploadSuccess(url: String) {
        TODO("Not yet implemented")
    }

    override fun refreshReportList(data: ReportListRecord) {
        TODO("Not yet implemented")
    }

    override fun loadReportList(data: ReportListRecord) {
        TODO("Not yet implemented")
    }

}